<!--$Id: newsite.so,v 1.7 2006/08/24 17:58:53 bostic Exp $-->
<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB Reference Guide: Connecting to a new site</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<table width="100%"><tr valign=top>
<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Berkeley DB Replication</dl></b></td>
<td align=right><a href="../rep/comm.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../rep/elect.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p align=center><b>Connecting to a new site</b></p>
<p>To add a new site to the replication group all that is needed
is for the client member to join.  Berkeley DB will perform an
internal initialization from the master to the client automatically
and will run recovery on the client to bring it up to date
with the master.</p>
<p>For applications that use the Base replication API, connecting to a
new site in the replication group happens whenever the
<a href="../../api_c/rep_message.html">DB_ENV-&gt;rep_process_message</a> method returns <a href="../../api_c/rep_message.html#DB_REP_NEWSITE">DB_REP_NEWSITE</a>.  The application
should assign the new site a local environment ID number, and all future
messages from the site passed to <a href="../../api_c/rep_message.html">DB_ENV-&gt;rep_process_message</a> should include that
environment ID number.  It is possible, of course, for the application
to be aware of a new site before the return of <a href="../../api_c/rep_message.html">DB_ENV-&gt;rep_process_message</a> (for
example, applications using connection-oriented protocols are likely to
detect new sites immediately, while applications using broadcast
protocols may not).</p>
<p>Regardless, in applications supporting the dynamic addition of database
environments to replication groups, environments joining an existing
replication group may need to provide contact information.  (For
example, in an application using TCP/IP sockets, a DNS name or IP
address might be a reasonable value to provide.)  This can be done using
the <b>cdata</b> parameter to the <a href="../../api_c/rep_start.html">DB_ENV-&gt;rep_start</a> method.  The information
referenced by <b>cdata</b> is wrapped in the initial contact message
sent by the new environment, and is provided to the existing members of
the group using the <b>rec</b> parameter returned by <a href="../../api_c/rep_message.html">DB_ENV-&gt;rep_process_message</a>.
If no additional information was provided for Berkeley DB to forward to the
existing members of the group, the <b>data</b> field of the <b>rec</b>
parameter passed to the <a href="../../api_c/rep_message.html">DB_ENV-&gt;rep_process_message</a> method will be NULL after
<a href="../../api_c/rep_message.html">DB_ENV-&gt;rep_process_message</a> returns <a href="../../api_c/rep_message.html#DB_REP_NEWSITE">DB_REP_NEWSITE</a>.</p>
<p>Replication Manager automatically distributes contact information using
the mechanisms previously described.</p>
<table width="100%"><tr><td><br></td><td align=right><a href="../rep/comm.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../rep/elect.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
</body>
</html>
